using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Web;

namespace Ares
{
    public partial class AddValue : Form
    {
        public AddValue()
        {
            InitializeComponent();
        }

        static public string GetValue()
        {
            AddValue f = new AddValue();
            if (f.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string str = f.TBName.Text + "=" + HttpUtility.UrlEncode(f.TBVal.Text);
                return str;
            }
            else
            {
                throw new Exception();
            }

        }

        static public string EditValue(string Value)
        {
            string n = Value.Substring(0, Value.IndexOf('='));
            string v = Value.Substring(Value.IndexOf('=')+1);
            v = HttpUtility.UrlDecode(v);
            
            AddValue f = new AddValue();
            f.TBName.Text = n;
            f.TBVal.Text = v;
            if (f.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string str = f.TBName.Text + "=" + HttpUtility.UrlEncode(f.TBVal.Text);
                return str;
            }
            else
            {
                throw new Exception();
            }
        }
            


        private void BtnOK_Click(object sender, EventArgs e)
        {
            this.DialogResult = System.Windows.Forms.DialogResult.OK;
            Close();
        }

        private void BtnCancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            Close();
        }
    }
}